package praktikumid.kaug;

import java.io.BufferedReader;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import java.net.URL;
import java.net.URLConnection;
import java.net.URLEncoder;

public class FeedNaide {

	public static void main(String[] args) throws Exception{
		URL url = new URL(
				"https://groups.google.com/group/iti0011/feed/rss_v2_0_msgs.xml");
		
		URLConnection conn = url.openConnection();
			conn.setRequestProperty("User-agent", "Mozilla/5.0");
		
		InputStream is = conn.getInputStream();
		
		BufferedReader br = new BufferedReader(
				new InputStreamReader(is));
		
//		String line = br.readLine();
		String line = null;
		String result = "";
		while ((line = br.readLine()) != null) {
			result += line;
		}
		
		String startTag = "<item>";
		
		int p = result.indexOf(startTag);
		String q = URLEncoder.encode("jou maailm", "UTF-8");
		result.split("<item>");
		
//		System.out.println(result.substring(p + 6));
		System.out.println(q);
	} // -main
	
	static int meetodXXXX() throws Exception {
		// 1
		// 2
		
		throw new Exception();
		
//		return 0;
	}
}
